VFG.EditPPoint=function(viewer,entity){
	this.viewer=viewer;
	this.tip=new VFG.Tip(viewer);
	this.entity=entity;
	this.position=entity.position||null;
	this.cartesian3;
	this.init();
}
VFG.EditPPoint.prototype.init=function(){
	var _this=this;
	this.cartesian3 = Cesium.Cartesian3.fromDegrees(this.position.x*1, this.position.y*1,this.position.z*1+1);
	this.orbitControls=new VFG.OrbitControls(this.viewer,{
		id:this.entity.id,
		position:this.cartesian3,
		scale:15,
		callback:function(position){
			_this.cartesian3=position;
			let LnLa = VFG.Util.getLnLaFormC3(_this.viewer, position);
			if (Cesium.defined(LnLa)) {
				let new_position={
					x:LnLa.x,
					y:LnLa.y,
					z:LnLa.z*1-1,
				};
				if(_this.change){
					_this.change({
						position:new_position
					});
				}
				if(_this.entity){
					_this.entity.update({
						position:new_position
					});
				}
			}
		}
	})
}


VFG.EditPPoint.prototype.on = function(type,callback) {
	if('change'==type){
		this.change=callback;
	}
};

VFG.EditPPoint.prototype.destroy = function() {
    if(this.orbitControls){
    	this.orbitControls.destroy();
    }
    if( this._handler){
    	this._handler.destroy();
    	this._handler = null;
    };
    if(this.tip){
    	this.tip.destroy();
    }
	delete this.orbitControls;
    delete this.viewer;
	return Cesium.destroyObject(this);
};
